<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>01</title>
</head>
<body>
<script>
    /*
     * 使用原型模式创建对象
     * 动态的添加对象的属性和方法
     *
     */
    function Animal() {}

    Animal.prototype.name = "Animal";
    Animal.prototype.sayName = function () {
        alert(this.name);
    }

    var a1 = new Animal();
    var a2 = new Animal();
    alert(a1.sayName == a2.sayName); //true
    a1.sayName();

    alert(Animal.prototype.constructor == Animal); //true
</script>
</body>
</html>